#objcopy -I elf64-x86-64 -O binary -R .note -R .comment system kernel.bin
#objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary system kernel.bin
#as --64 -o head.o head.s
#objcopy --only-keep-debug system kernel.sym
#gcc -m64 -g -fomit-frame-pointer -fno-stack-protector -traditional -c head.s
all: system
	objcopy -I elf64-x86-64 -S -R ".eh_frame" -R ".comment" -O binary system kernel.bin

system:	head.o main.o lib.o printk.o font.o
	ld -b elf64-x86-64 -o system head.o main.o lib.o printk.o font.o -T Kernel.lds 

main.o:	main.c
	gcc -g -mcmodel=large -fno-builtin -m64 -c main.c

head.o:	head.S
	gcc -E  head.S > head.s
	as --64 -g -o head.o head.s

lib.o:	lib.c
	gcc -g -static -mcmodel=large -fno-builtin -m64 -c lib.c -fno-stack-protector 

font.o:	font.c
	gcc -g -static -mcmodel=large -fno-builtin -m64 -c font.c -fno-stack-protector		

printk.o: printk.c
	gcc -g -static -mcmodel=large -fno-builtin -m64 -c printk.c -fno-stack-protector

clean:
	rm -rf *.o *.s~ *.s *.S~ *.c~ *.h~ system  Makefile~ Kernel.lds~ kernel.bin 	